<?php defined('InNcPHP') or exit('Access Invalid!');?>
<div class="diglogBg"></div>
<div class="diglogBox">
    <div class="closeBox">关闭窗口</div>
    <div id="baiduMap" class="mapBox"></div>
</div>
<style type="text/css">
    .diglogBg{position:fixed;width:100%;height:100%;top:0;left:0;background:rgba(0,0,0,0.5);z-index:99;}
    .diglogBox{width:660px;height:400px;background:#fff;left:50%;top:50%;position:fixed;z-index:100;margin-top:-200px;margin-left:-330px;}
    .closeBox{position:absolute;height:30px;background:#fff;font-size:14px;text-align:center;line-height:30px;top:-33px;right:0;z-index:101;padding:0 10px;cursor:pointer;}
    .mapBox{width:100%;height:100%;}
</style>
<script type="text/javascript">
    $(function(){

        $(document).on("click",".closeBox",function(){
            $(".diglogBg,.diglogBox").remove();
        });

        var map = new AMap.Map('baiduMap',{
            zoom:15
        });
        AMap.plugin(['AMap.ToolBar','AMap.Scale','AMap.OverView'],
            function(){
            });

        var geocoder = new AMap.Geocoder();
        var marker = new AMap.Marker({
            map:map,
            bubble:true
        });
        var address = "<?php echo $output['region'];?>"+"<?php echo $output['store_address'];?>";
        AMap.plugin('AMap.Geocoder',function(){
            geocoder.getLocation(address,function(status,result){
                if(status=='complete'&&result.geocodes.length){
                    marker.setPosition(result.geocodes[0].location);
                    map.setCenter(marker.getPosition());
                    $("#store_location").val(result.geocodes[0].location);
                }
            });
        });

        AMap.event.addListener(map,'click',function(e){
            map.remove(marker);
            AMap.plugin('AMap.Geocoder',function(){
                var len=e.lnglat.getLng()+","+e.lnglat.getLat();
                marker = new AMap.Marker({
                    position: len.split(","),
                    map:map,
                    bubble:true
                });
            });

            $("#store_location").val(e.lnglat.getLng()+","+e.lnglat.getLat());

        });



    });



</script>
